﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using WeifenLuo.WinFormsUI.Docking;
namespace BYManageInfoSystem
{
    public partial class Frm_BGDComeBack : DockContent
    {
        private DGBY.BLL.PaidanRegisterTab m_bllPaidanRegisterTab = new DGBY.BLL.PaidanRegisterTab();
        private DGBY.BLL.YSMethodTab m_bllYSMethodTab = new DGBY.BLL.YSMethodTab();
        private DGBY.BLL.JNHYPosTab m_bllJNHYPosTab = new DGBY.BLL.JNHYPosTab();
        private DGBY.BLL.MDCountryTab m_bllMDCountryTab = new DGBY.BLL.MDCountryTab();
        private DGBY.BLL.ChengJFSTab m_bllChengJFSTab = new DGBY.BLL.ChengJFSTab();
        private DGBY.BLL.MDPortTab m_bllMDPortTab = new DGBY.BLL.MDPortTab();
        private DGBY.BLL.BZSortTab m_bllBZSortTab = new DGBY.BLL.BZSortTab();
        private DGBY.BLL.BGHDataTab m_bllBGHDataTab = new DGBY.BLL.BGHDataTab();

        private DGBY.BLL.HaiGuanTab m_bllHaiGuanTab = new DGBY.BLL.HaiGuanTab();
        private DGBY.BLL.MaoYiFSTab m_bllMaoYiFSTab = new DGBY.BLL.MaoYiFSTab();
        private DGBY.BLL.JieHuiFSTab m_bllJieHuiFSTab = new DGBY.BLL.JieHuiFSTab();
        private DGBY.BLL.ZhengMXZTab m_bllZhengMXZTab = new DGBY.BLL.ZhengMXZTab();
        private DGBY.BLL.BGCKHTTab m_bllBGCKHTTab = new DGBY.BLL.BGCKHTTab();

        private DGBY.BLL.NumDanWeiTab m_bllNumDanWeiTab = new DGBY.BLL.NumDanWeiTab();
        private DGBY.BLL.BiZhiTab m_bllBiZhiTab = new DGBY.BLL.BiZhiTab();

        private DGBY.BLL.BGDComeBackTab m_bllBGDComeBackTab = new DGBY.BLL.BGDComeBackTab();
        private DGBY.BLL.CargoBoxTab m_bllCargoBoxTab = new DGBY.BLL.CargoBoxTab();
        private DGBY.BLL.BGDComeBackGoodsMXTab m_bllBGDComeBackGoodsMXTab = new DGBY.BLL.BGDComeBackGoodsMXTab();
        private DGBY.BLL.HxdNoTab m_bllHxdNoTab = new DGBY.BLL.HxdNoTab();

        private int m_nSelectBGDComeBackTabID = 0;
        private int m_nSelectBGDComeBackGoodsMXTabID = 0;

        private bool m_bFlag = false;

        public Frm_BGDComeBack()
        {
            InitializeComponent();
        }

        private void Frm_BGDComeBack_Load(object sender, EventArgs e)
        {
            this.groupBoxGoodsDetail.Visible = false;
            InitCombox();

  
        }

        private void InitCombox()
        {
            DataSet ds = m_bllPaidanRegisterTab.GetAllPaiDanList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxContractNo.DataSource = ds.Tables[0];
                this.comboBoxContractNo.ValueMember = "PaidanRegisterTabID";
                this.comboBoxContractNo.DisplayMember = "合同编号";
                this.comboBoxContractNo.AutoCompleteSource = AutoCompleteSource.ListItems;
                this.comboBoxContractNo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                this.comboBoxContractNo.SelectedValue = Frm_Main.m_nContractSelectValue;
            }
            ds = m_bllYSMethodTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxTransWay.DataSource = ds.Tables[0];
                this.comboBoxTransWay.DisplayMember = "运输方式";
                this.comboBoxTransWay.ValueMember = "YSMethodTabID";
                this.comboBoxTransWay.SelectedIndex = 0;
            }

            ds = m_bllJNHYPosTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxJNHYDi.DataSource = ds.Tables[0];
                this.comboBoxJNHYDi.DisplayMember = "境内货源地";
                this.comboBoxJNHYDi.ValueMember = "JNHYPosTabID";
                this.comboBoxJNHYDi.SelectedIndex = 0;
            }

            ds = m_bllMDCountryTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxArriveNation.DataSource = ds.Tables[0];
                this.comboBoxArriveNation.DisplayMember = "国家名称";
                this.comboBoxArriveNation.ValueMember = "MDCountryTabID";
                this.comboBoxArriveNation.SelectedIndex = 0;
            }
            ds = m_bllChengJFSTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxCJiaoWay.DataSource = ds.Tables[0];
                this.comboBoxCJiaoWay.DisplayMember = "成交方式";
                this.comboBoxCJiaoWay.ValueMember = "ChengJFSTabID";
                this.comboBoxCJiaoWay.SelectedIndex = 0;
            }
            ds = m_bllMDPortTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxTargetPort.DataSource = ds.Tables[0];
                this.comboBoxTargetPort.DisplayMember = "港口名称";
                this.comboBoxTargetPort.ValueMember = "MDPortTabID";
                this.comboBoxTargetPort.SelectedIndex = 0;
            }
            ds = m_bllBZSortTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxWrapCate.DataSource = ds.Tables[0];
                this.comboBoxWrapCate.DisplayMember = "包装种类";
                this.comboBoxWrapCate.ValueMember = "BZSortTabID";
                this.comboBoxWrapCate.SelectedIndex = 0;
            }

            ds = m_bllBGHDataTab.GetList("");      
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxBGHName.DataSource = ds.Tables[0];
                this.comboBoxBGHName.DisplayMember = "报关行名称";
                this.comboBoxBGHName.ValueMember = "BGHDataTabID";
                this.comboBoxBGHName.SelectedIndex = 0;
            }

            ds = m_bllHaiGuanTab.GetList("");      
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxCKouPort.DataSource = ds.Tables[0];
                this.comboBoxCKouPort.DisplayMember = "海关名称";
                this.comboBoxCKouPort.ValueMember = "HaiGuanTabID";
                this.comboBoxCKouPort.SelectedIndex = 0;
            }
                        
            ds = m_bllMaoYiFSTab.GetList("");      
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxMYiWay.DataSource = ds.Tables[0];
                this.comboBoxMYiWay.DisplayMember = "贸易方式";
                this.comboBoxMYiWay.ValueMember = "MaoYiFSTabID";
                this.comboBoxMYiWay.SelectedIndex = 0;
            }

            ds = m_bllJieHuiFSTab.GetList("");      
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxJHuiWay.DataSource = ds.Tables[0];
                this.comboBoxJHuiWay.DisplayMember = "结汇方式";
                this.comboBoxJHuiWay.ValueMember = "JieHuiFSTabID";
                this.comboBoxJHuiWay.SelectedIndex = 0;
            }
            ds = m_bllZhengMXZTab.GetList("");      
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxZhengMXZhi.DataSource = ds.Tables[0];
                this.comboBoxZhengMXZhi.DisplayMember = "征免性质";
                this.comboBoxZhengMXZhi.ValueMember = "ZhengMXZTabID";
                this.comboBoxZhengMXZhi.SelectedIndex = 0;
            }
            
            ds = m_bllNumDanWeiTab.GetList("");      
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxUnit.DataSource = ds.Tables[0];
                this.comboBoxUnit.DisplayMember = "单位名称";
                this.comboBoxUnit.ValueMember = "NumDanWeiTabID";
                this.comboBoxUnit.SelectedIndex = 0;
            }
            ds = m_bllBiZhiTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxCoinUnit2.DataSource = ds.Tables[0];
                this.comboBoxCoinUnit2.DisplayMember = "币制名称";
                this.comboBoxCoinUnit2.ValueMember = "BiZhiTabID";
                this.comboBoxCoinUnit2.SelectedIndex = 0;
            }
        }

        private void ShowAllRecordInDataGridView()
        {
            DataSet ds = m_bllBGDComeBackTab.ShowOneBGDComeBackkRec("");

            ultraGrid1.DataSource = null;
            ultraGrid2.DataSource = null;
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {

                ultraGrid1.DataSource = ds.Tables[0];
                ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
            }
        }

        private void ShowAllMXRecordInDataGridView(string strBGDComeBackTabID, string strTargetNation)
        {

            DataSet m_ds = m_bllBGDComeBackGoodsMXTab.ShowAllBGDComeBackMX("BGDComeBackGoodsMXTab.BGDComeBackTabID = '" + strBGDComeBackTabID + "'", strTargetNation);
            ultraGrid2.DataSource = null;
            if (m_ds.Tables.Count > 0 && m_ds.Tables[0].Rows.Count > 0)
            {

                int nNumTotal = 0;
               // Decimal dtSingleJinE = 0;
                Decimal dtTotalJinE = 0;

                for (int i = 0; i < m_ds.Tables[0].Rows.Count; i++)
                {
                    nNumTotal += Convert.ToInt32(m_ds.Tables[0].Rows[i]["数量"].ToString(), 10);
                    //dtSingleJinE += Convert.ToDecimal(m_ds.Tables[0].Rows[i]["单价"].ToString());
                    dtTotalJinE += Convert.ToDecimal(m_ds.Tables[0].Rows[i]["总价"].ToString());
                }

                DataRow dr = m_ds.Tables[0].NewRow();
   
                dr["数量"] = nNumTotal;
               // dr["单价"] = dtSingleJinE;
                dr["总价"] = dtTotalJinE;
                dr["商品编号"] = "合计";
                m_ds.Tables[0].Rows.Add(dr.ItemArray);
                ultraGrid2.DataSource = m_ds.Tables[0];
                ultraGrid2.DisplayLayout.Bands[0].Columns[0].Hidden = true;
                ultraGrid2.DisplayLayout.Bands[0].Columns[1].Hidden = true;
                ultraGrid2.DisplayLayout.Bands[0].Columns[2].Hidden = true;
            }
        }

        private void ShowContractSheetByContractNo(string strContractNo)
        {
            int nID = Convert.ToInt32(strContractNo, 10);

            DataSet ds = m_bllBGDComeBackTab.ShowOneBGDComeBackkRec("PaidanRegisterTab.PaidanRegisterTabID = '" + nID + "'");
            ultraGrid1.DataSource = null;
            


            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                int nIsSyncComplete = Convert.ToInt32(ds.Tables[0].Rows[0]["同步已完成"].ToString(), 10);
                this.button1.Enabled = nIsSyncComplete > 0 ? false : true;
                ultraGrid1.DataSource = ds.Tables[0];
                ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
                string strBGDComeBackTabID = ds.Tables[0].Rows[0]["BGDComeBackTabID"].ToString();
                this.comboBoxArriveNation.Text = ds.Tables[0].Rows[0]["抵运国"].ToString();
                m_nSelectBGDComeBackTabID = Convert.ToInt32(strBGDComeBackTabID, 10);
                ShowAllMXRecordInDataGridView(strBGDComeBackTabID, this.comboBoxArriveNation.Text);
                ds = m_bllHxdNoTab.GetList("PaidanRegisterTabID = '" + nID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxBGDNo.Text = ds.Tables[0].Rows[0]["BGDNo"].ToString();
                    this.dateTimePickerSBDate.Value = (DateTime)ds.Tables[0].Rows[0]["SBDate"];
                }
            }
            else
            {
                ds = m_bllBGCKHTTab.ShowOneOutContractRecFromCK("BGCKHTTab.PaidanRegisterTabID = '" + nID + "'");

                this.textBoxBYComp.Text = ds.Tables[0].Rows[0]["卖方"].ToString();
                this.comboBoxJNHYDi.Text = ds.Tables[0].Rows[0]["境内货源地"].ToString();
                this.comboBoxWrapCate.Text = ds.Tables[0].Rows[0]["包装"].ToString();
                this.comboBoxArriveNation.Text = ds.Tables[0].Rows[0]["目的国家"].ToString();

                ds = m_bllHxdNoTab.GetList("PaidanRegisterTabID = '" + nID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxBGDNo.Text = ds.Tables[0].Rows[0]["BGDNo"].ToString();
                    this.dateTimePickerSBDate.Value = (DateTime)ds.Tables[0].Rows[0]["SBDate"];
                }

            }
        }

        private void comboBoxContractNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string str = this.comboBoxContractNo.SelectedValue.ToString();
                ShowContractSheetByContractNo(str);

            }
            catch { }
        }

        private void buttonShowAll_Click(object sender, EventArgs e)
        {
            ShowAllRecordInDataGridView();
            this.ultraGrid1.Dock = DockStyle.Fill;
            this.groupBoxGoodsDetail.Visible = false;
        }

        private void buttonAddBGDComebackSheet_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.BGDComeBackTab modelBGDComeBackTab = new DGBY.Model.BGDComeBackTab();

                modelBGDComeBackTab.BGDNo = this.textBoxBGDNo.Text;
                modelBGDComeBackTab.FHDWName = this.textBoxSendGoodsComp.Text;
                modelBGDComeBackTab.PZWH = this.textBoxPermitNo.Text;

                modelBGDComeBackTab.SFDZName = this.textBoxSFDZhengName.Text;
                modelBGDComeBackTab.SFDZNo = this.textBoxSFDZhengNo.Text;
                modelBGDComeBackTab.Note = this.textBoxNote.Text;

                modelBGDComeBackTab.SBDate = this.dateTimePickerSBDate.Value;
                modelBGDComeBackTab.CKouDate = this.dateTimePickerCKouDate.Value;
                if (this.comboBoxCoinUnit2.SelectedValue != null)
                    modelBGDComeBackTab.BiZhiTabID = Convert.ToInt32(this.comboBoxCoinUnit2.SelectedValue.ToString(), 10);
                if (this.textBoxKaiPiaoHuiLv.Text != "")
                    modelBGDComeBackTab.KaiPiaoHuiLv = Convert.ToDecimal(this.textBoxKaiPiaoHuiLv.Text);
                else
                    modelBGDComeBackTab.KaiPiaoHuiLv = 0;

                if (this.comboBoxContractNo.SelectedValue != null)
                    modelBGDComeBackTab.PaidanRegisterTabID = Convert.ToInt32(this.comboBoxContractNo.SelectedValue.ToString(), 10);
                if (this.comboBoxTransWay.SelectedValue != null)
                    modelBGDComeBackTab.YSMethodTabID = Convert.ToInt32(this.comboBoxTransWay.SelectedValue.ToString(), 10);
                if (this.comboBoxArriveNation.SelectedValue != null)
                    modelBGDComeBackTab.MDCountryTabID = Convert.ToInt32(this.comboBoxArriveNation.SelectedValue.ToString(), 10);
                if (this.comboBoxJNHYDi.SelectedValue != null)
                    modelBGDComeBackTab.JNHYPosTabID = Convert.ToInt32(this.comboBoxJNHYDi.SelectedValue.ToString(), 10);
                if (this.comboBoxCJiaoWay.SelectedValue != null)
                    modelBGDComeBackTab.ChengJFSTabID = Convert.ToInt32(this.comboBoxCJiaoWay.SelectedValue.ToString(), 10);

                if (this.comboBoxTargetPort.SelectedValue != null)
                    modelBGDComeBackTab.MDPortTabID = Convert.ToInt32(this.comboBoxTargetPort.SelectedValue.ToString(), 10);
                if (this.comboBoxWrapCate.SelectedValue != null)
                    modelBGDComeBackTab.BZSortTabID = Convert.ToInt32(this.comboBoxWrapCate.SelectedValue.ToString(), 10);
                if (this.comboBoxBGHName.SelectedValue != null)
                    modelBGDComeBackTab.BGHDataTabID = Convert.ToInt32(this.comboBoxBGHName.SelectedValue.ToString(), 10);

                if (this.comboBoxCKouPort.SelectedValue != null)
                    modelBGDComeBackTab.HaiGuanTabID = Convert.ToInt32(this.comboBoxCKouPort.SelectedValue.ToString(), 10);
                if (this.comboBoxMYiWay.SelectedValue != null)
                    modelBGDComeBackTab.MaoYiFSTabID = Convert.ToInt32(this.comboBoxMYiWay.SelectedValue.ToString(), 10);
                if (this.comboBoxJHuiWay.SelectedValue != null)
                    modelBGDComeBackTab.JieHuiFSTabID = Convert.ToInt32(this.comboBoxJHuiWay.SelectedValue.ToString(), 10);
                if (this.comboBoxZhengMXZhi.SelectedValue != null)
                    modelBGDComeBackTab.ZhengMXZTabID = Convert.ToInt32(this.comboBoxZhengMXZhi.SelectedValue.ToString(), 10);


                int nBGDComeBackTabID = m_bllBGDComeBackTab.Add(modelBGDComeBackTab);


                m_bllBGDComeBackGoodsMXTab.InsertGoodsMX(this.comboBoxContractNo.Text, nBGDComeBackTabID);
                ShowContractSheetByContractNo(modelBGDComeBackTab.PaidanRegisterTabID.ToString());
                //MessageBox.Show("数据添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
          
        }

        private void buttonCargoInfo_Click(object sender, EventArgs e)
        {
            Frm_CargoBoxInfo frm_CargoBoxInfo = new Frm_CargoBoxInfo(m_nSelectBGDComeBackTabID);
            frm_CargoBoxInfo.StartPosition = FormStartPosition.CenterScreen;
            frm_CargoBoxInfo.ShowDialog();
        }


        private void cellBGDComeBackTabClick()
        {
            this.ultraGrid1.Dock = DockStyle.None;
            this.groupBoxGoodsDetail.Visible = true;
            DGBY.Model.BGDComeBackTab modelBGDComeBackTab = m_bllBGDComeBackTab.GetModel(m_nSelectBGDComeBackTabID);
            if (modelBGDComeBackTab != null)
            {
                this.textBoxBGDNo.Text = modelBGDComeBackTab.BGDNo;
                this.textBoxSendGoodsComp.Text = modelBGDComeBackTab.FHDWName;
                this.textBoxPermitNo.Text = modelBGDComeBackTab.PZWH;
                this.textBoxKaiPiaoHuiLv.Text = modelBGDComeBackTab.KaiPiaoHuiLv.ToString();

                this.textBoxSFDZhengName.Text = modelBGDComeBackTab.SFDZName;
                this.textBoxSFDZhengNo.Text = modelBGDComeBackTab.SFDZNo;
                this.textBoxNote.Text = modelBGDComeBackTab.Note;

                this.dateTimePickerSBDate.Value = (System.DateTime)modelBGDComeBackTab.SBDate;
                this.dateTimePickerCKouDate.Value = (System.DateTime)modelBGDComeBackTab.CKouDate;

                DataSet ds = m_bllCargoBoxTab.GetCargoBoxCounts("CargoBoxTab.BGDComeBackTabID = " + m_nSelectBGDComeBackTabID.ToString());
                
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxGuiNum.Text = ds.Tables[0].Rows[0]["CargoBoxCounts"].ToString();
                }


                if (modelBGDComeBackTab.PaidanRegisterTabID != null)
                    this.comboBoxContractNo.SelectedValue = modelBGDComeBackTab.PaidanRegisterTabID;
                if (modelBGDComeBackTab.YSMethodTabID != null)
                    this.comboBoxTransWay.SelectedValue = modelBGDComeBackTab.YSMethodTabID;
                if (modelBGDComeBackTab.MDCountryTabID != null)
                    this.comboBoxArriveNation.SelectedValue = modelBGDComeBackTab.MDCountryTabID;
                if (modelBGDComeBackTab.JNHYPosTabID != null)
                    this.comboBoxJNHYDi.SelectedValue = modelBGDComeBackTab.JNHYPosTabID;
                if (modelBGDComeBackTab.ChengJFSTabID != null)
                    this.comboBoxCJiaoWay.SelectedValue = modelBGDComeBackTab.ChengJFSTabID;


                if (modelBGDComeBackTab.MDPortTabID != null)
                    this.comboBoxTargetPort.SelectedValue = modelBGDComeBackTab.MDPortTabID;
                if (modelBGDComeBackTab.BZSortTabID != null)
                    this.comboBoxWrapCate.SelectedValue = modelBGDComeBackTab.BZSortTabID;
                if (modelBGDComeBackTab.BGHDataTabID != null)
                    this.comboBoxBGHName.SelectedValue = modelBGDComeBackTab.BGHDataTabID;


                if (modelBGDComeBackTab.HaiGuanTabID != null)
                    this.comboBoxCKouPort.SelectedValue = modelBGDComeBackTab.HaiGuanTabID;
                if (modelBGDComeBackTab.MaoYiFSTabID != null)
                    this.comboBoxMYiWay.SelectedValue = modelBGDComeBackTab.MaoYiFSTabID;
                if (modelBGDComeBackTab.JieHuiFSTabID != null)
                    this.comboBoxJHuiWay.SelectedValue = modelBGDComeBackTab.JieHuiFSTabID;
                if (modelBGDComeBackTab.ZhengMXZTabID != null)
                    this.comboBoxZhengMXZhi.SelectedValue = modelBGDComeBackTab.ZhengMXZTabID;


                ds = m_bllBGCKHTTab.ShowOneOutContractRecFromCK("BGCKHTTab.PaidanRegisterTabID = '" + modelBGDComeBackTab.PaidanRegisterTabID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxBYComp.Text = ds.Tables[0].Rows[0]["卖方"].ToString();
                }
                

                //ShowAllMXRecordInDataGridView(m_nSelectBGPackingTabID);

            }
        }

        public void SyncBGDComeBackMX(string strContract)
        {
            DataSet ds = m_bllBGDComeBackTab.ShowOneBGDComeBackkRec("PaidanRegisterTab.ContractCode = '" + strContract + "'");
            int nBGDComeBackTabID = 0;
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                //int nIsSyncComplete = Convert.ToInt32(ds.Tables[0].Rows[0]["同步已完成"].ToString(), 10);
                //if(nIsSyncComplete == 0)
                {
                    nBGDComeBackTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["BGDComeBackTabID"].ToString(), 10);
                }
            }
            else
            {
                return;
            }

            DataSet m_ds = m_bllBGDComeBackGoodsMXTab.ShowAllBGDComeBackMX("BGDComeBackGoodsMXTab.BGDComeBackTabID = '" + nBGDComeBackTabID + "'", "");

            if (m_ds.Tables.Count > 0 && m_ds.Tables[0].Rows.Count > 0)
            {

            }
            else
            {
                //这里转移到修改合同时进行处理
                ds = m_bllBGCKHTTab.ShowAllCKHTMXEx(strContract);
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTab = new DGBY.Model.BGDComeBackGoodsMXTab();

                        modelBGDComeBackGoodsMXTab.GoodsNo = "";
                        modelBGDComeBackGoodsMXTab.GoodsMXName = ds.Tables[0].Rows[i]["商品名称"].ToString();
                        modelBGDComeBackGoodsMXTab.GGXHZDEtc = ds.Tables[0].Rows[i]["质地"].ToString();
                        modelBGDComeBackGoodsMXTab.GGXHZDEtc2 = ds.Tables[0].Rows[i]["规格型号"].ToString();
                        modelBGDComeBackGoodsMXTab.FPieceNum = Convert.ToInt32(ds.Tables[0].Rows[i]["数量"].ToString(), 10);
                        modelBGDComeBackGoodsMXTab.SingleCost = Convert.ToDecimal(ds.Tables[0].Rows[i]["单价"].ToString());
                        modelBGDComeBackGoodsMXTab.TotalCost = Convert.ToDecimal(ds.Tables[0].Rows[i]["金额"].ToString());
                        modelBGDComeBackGoodsMXTab.ZhengMian = "";
                        modelBGDComeBackGoodsMXTab.BGDComeBackTabID = nBGDComeBackTabID;

                        //   modelBGDComeBackGoodsMXTab.BiZhiTabID = Convert.ToInt32(ds.Tables[0].Rows[i]["币制"].ToString(), 10);
                        modelBGDComeBackGoodsMXTab.NumDanWeiTabID = Convert.ToInt32(ds.Tables[0].Rows[i]["单位"].ToString(), 10);
                        modelBGDComeBackGoodsMXTab.BGSeqNo = Convert.ToInt32(ds.Tables[0].Rows[i]["trueBGSeqNo"].ToString(), 10);
                        m_bllBGDComeBackGoodsMXTab.Add(modelBGDComeBackGoodsMXTab);
                    }
                }
            }

            ds = m_bllCargoBoxTab.GetCargoBoxCounts("CargoBoxTab.BGDComeBackTabID = " + nBGDComeBackTabID.ToString());

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                int nCargoBoxCounts = Convert.ToInt32(ds.Tables[0].Rows[0]["CargoBoxCounts"].ToString(), 10);
                if (nCargoBoxCounts == 0)
                {
                    DataSet dsTemp = m_bllBGDComeBackTab.GetGuiNoInfo("BGDComeBackTab.BGDComeBackTabID = '" + nBGDComeBackTabID + "'");
                    if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 0; i < dsTemp.Tables[0].Rows.Count; i++)
                        {
                            DGBY.Model.CargoBoxTab modelCargoBoxTab = new DGBY.Model.CargoBoxTab();

                            modelCargoBoxTab.CargoBoxNo = dsTemp.Tables[0].Rows[i]["柜号"].ToString();
                            modelCargoBoxTab.GuiXingTabID = Convert.ToInt32(dsTemp.Tables[0].Rows[0]["柜型ID"].ToString(), 10);
                            modelCargoBoxTab.BGDComeBackTabID = nBGDComeBackTabID;

                            m_bllCargoBoxTab.Add(modelCargoBoxTab);
                        }
                    }
                }
            }
        }

        private void buttonModifyBGDComebackSheet_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.BGDComeBackTab modelBGDComeBackTabOld = m_bllBGDComeBackTab.GetModel(m_nSelectBGDComeBackTabID);
                if (modelBGDComeBackTabOld == null)
                {
                    MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                DGBY.Model.BGDComeBackTab modelBGDComeBackTab = new DGBY.Model.BGDComeBackTab();

                modelBGDComeBackTab.BGDComeBackTabID = m_nSelectBGDComeBackTabID;

                modelBGDComeBackTab.BGDNo = this.textBoxBGDNo.Text;
                modelBGDComeBackTab.FHDWName = this.textBoxSendGoodsComp.Text;
                modelBGDComeBackTab.PZWH = this.textBoxPermitNo.Text;
                modelBGDComeBackTab.TotalPieceNum = modelBGDComeBackTabOld.TotalPieceNum;
                modelBGDComeBackTab.TotalMaoWeight = modelBGDComeBackTabOld.TotalMaoWeight;
                modelBGDComeBackTab.TotalJingWeight = modelBGDComeBackTabOld.TotalJingWeight;
                modelBGDComeBackTab.SFDZName = this.textBoxSFDZhengName.Text;
                modelBGDComeBackTab.SFDZNo = this.textBoxSFDZhengNo.Text;
                modelBGDComeBackTab.Note = this.textBoxNote.Text;
                if (this.textBoxKaiPiaoHuiLv.Text != "")
                    modelBGDComeBackTab.KaiPiaoHuiLv = Convert.ToDecimal(this.textBoxKaiPiaoHuiLv.Text);
                else
                    modelBGDComeBackTab.KaiPiaoHuiLv = 0;
                modelBGDComeBackTab.SBDate = this.dateTimePickerSBDate.Value;
                modelBGDComeBackTab.CKouDate = this.dateTimePickerCKouDate.Value;
                if (this.comboBoxCoinUnit2.SelectedValue != null)
                    modelBGDComeBackTab.BiZhiTabID = Convert.ToInt32(this.comboBoxCoinUnit2.SelectedValue.ToString(), 10);
                if (this.comboBoxContractNo.SelectedValue != null)
                    modelBGDComeBackTab.PaidanRegisterTabID = Convert.ToInt32(this.comboBoxContractNo.SelectedValue.ToString(), 10);
                if (this.comboBoxTransWay.SelectedValue != null)
                    modelBGDComeBackTab.YSMethodTabID = Convert.ToInt32(this.comboBoxTransWay.SelectedValue.ToString(), 10);
                if (this.comboBoxArriveNation.SelectedValue != null)
                    modelBGDComeBackTab.MDCountryTabID = Convert.ToInt32(this.comboBoxArriveNation.SelectedValue.ToString(), 10);
                if (this.comboBoxJNHYDi.SelectedValue != null)
                    modelBGDComeBackTab.JNHYPosTabID = Convert.ToInt32(this.comboBoxJNHYDi.SelectedValue.ToString(), 10);
                if (this.comboBoxCJiaoWay.SelectedValue != null)
                    modelBGDComeBackTab.ChengJFSTabID = Convert.ToInt32(this.comboBoxCJiaoWay.SelectedValue.ToString(), 10);

                if (this.comboBoxTargetPort.SelectedValue != null)
                    modelBGDComeBackTab.MDPortTabID = Convert.ToInt32(this.comboBoxTargetPort.SelectedValue.ToString(), 10);
                if (this.comboBoxWrapCate.SelectedValue != null)
                    modelBGDComeBackTab.BZSortTabID = Convert.ToInt32(this.comboBoxWrapCate.SelectedValue.ToString(), 10);
                if (this.comboBoxBGHName.SelectedValue != null)
                    modelBGDComeBackTab.BGHDataTabID = Convert.ToInt32(this.comboBoxBGHName.SelectedValue.ToString(), 10);

                if (this.comboBoxCKouPort.SelectedValue != null)
                    modelBGDComeBackTab.HaiGuanTabID = Convert.ToInt32(this.comboBoxCKouPort.SelectedValue.ToString(), 10);
                if (this.comboBoxMYiWay.SelectedValue != null)
                    modelBGDComeBackTab.MaoYiFSTabID = Convert.ToInt32(this.comboBoxMYiWay.SelectedValue.ToString(), 10);
                if (this.comboBoxJHuiWay.SelectedValue != null)
                    modelBGDComeBackTab.JieHuiFSTabID = Convert.ToInt32(this.comboBoxJHuiWay.SelectedValue.ToString(), 10);
                if (this.comboBoxZhengMXZhi.SelectedValue != null)
                    modelBGDComeBackTab.ZhengMXZTabID = Convert.ToInt32(this.comboBoxZhengMXZhi.SelectedValue.ToString(), 10);


                m_bllBGDComeBackTab.Update(modelBGDComeBackTab);

                SyncBGDComeBackMX(this.comboBoxContractNo.Text);
              


                ShowContractSheetByContractNo(modelBGDComeBackTab.PaidanRegisterTabID.ToString());

                MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
           
        }

        private void buttonDelBGDComebackSheet_Click(object sender, EventArgs e)
        {
            DGBY.Model.BGDComeBackTab modelBGDComeBackTabOld = m_bllBGDComeBackTab.GetModel(m_nSelectBGDComeBackTabID);
            if (modelBGDComeBackTabOld == null)
            {
                MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("确实要删除该条记录!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                m_bllBGDComeBackTab.Delete(m_nSelectBGDComeBackTabID);

                ShowContractSheetByContractNo(modelBGDComeBackTabOld.PaidanRegisterTabID.ToString());
                MessageBox.Show("数据删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);


                this.textBoxBGDNo.Text = "";
                this.textBoxSendGoodsComp.Text = "";
                this.textBoxPermitNo.Text = "";

                this.textBoxSFDZhengName.Text = "";
                this.textBoxSFDZhengNo.Text = "";
                this.textBoxNote.Text = "";

                return;
            }
        }

        private void cellBGDComeBackGoodsMXTabClick()
        {
            DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTab = m_bllBGDComeBackGoodsMXTab.GetModel(m_nSelectBGDComeBackGoodsMXTabID);
            if (modelBGDComeBackGoodsMXTab != null)
            {
                this.textBoxGoodsNoDetail.Text = modelBGDComeBackGoodsMXTab.GoodsNo;
                this.textBoxGoodsName.Text = modelBGDComeBackGoodsMXTab.GoodsMXName;
                this.textBoxMerial.Text = modelBGDComeBackGoodsMXTab.GGXHZDEtc;
                this.textBoxGuiGe.Text = modelBGDComeBackGoodsMXTab.GGXHZDEtc2;
                this.textBoxNum.Text = modelBGDComeBackGoodsMXTab.FPieceNum.ToString();
                this.textBoxSingleCost.Text = modelBGDComeBackGoodsMXTab.SingleCost.ToString();
                this.textBoxTotalPrice.Text = modelBGDComeBackGoodsMXTab.TotalCost.ToString();
                this.textBoxZMianDetail.Text = modelBGDComeBackGoodsMXTab.ZhengMian;



                if (modelBGDComeBackGoodsMXTab.NumDanWeiTabID != null)
                    this.comboBoxUnit.SelectedValue = modelBGDComeBackGoodsMXTab.NumDanWeiTabID;

            }
        }





    
        private bool IsNum(string strInput)
        {
            return Regex.IsMatch(strInput, @"^[1-9]+\d*$");
        }

        private bool ValidDate(string strInput)
        {
            if (strInput.Length != 8)
                return false;
            else
                return IsNum(strInput);
        }
       

   

        private void button1_Click(object sender, EventArgs e)
        {
            DGBY.Model.BGDComeBackTab modelBGDComeBackTabOld = m_bllBGDComeBackTab.GetModel(m_nSelectBGDComeBackTabID);
            if (modelBGDComeBackTabOld == null)
            {
                MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            modelBGDComeBackTabOld.IsSyncComplete = 1;
            m_bllBGDComeBackTab.Update(modelBGDComeBackTabOld);
            this.button1.Enabled = false;
        }
        private void buttonGoodsDetailAdd_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTab = new DGBY.Model.BGDComeBackGoodsMXTab();

                modelBGDComeBackGoodsMXTab.GoodsNo = this.textBoxGoodsNoDetail.Text;
                modelBGDComeBackGoodsMXTab.GoodsMXName = this.textBoxGoodsName.Text;
                modelBGDComeBackGoodsMXTab.GGXHZDEtc = this.textBoxMerial.Text;
                modelBGDComeBackGoodsMXTab.GGXHZDEtc2 = this.textBoxGuiGe.Text;
                modelBGDComeBackGoodsMXTab.FPieceNum = Convert.ToInt32(this.textBoxNum.Text, 10);
                modelBGDComeBackGoodsMXTab.SingleCost = Convert.ToDecimal(this.textBoxSingleCost.Text);
                modelBGDComeBackGoodsMXTab.TotalCost = Convert.ToDecimal(this.textBoxTotalPrice.Text);
                modelBGDComeBackGoodsMXTab.ZhengMian = this.textBoxZMianDetail.Text;
                modelBGDComeBackGoodsMXTab.BGDComeBackTabID = m_nSelectBGDComeBackTabID;



                if (this.comboBoxUnit.SelectedValue != null)
                    modelBGDComeBackGoodsMXTab.NumDanWeiTabID = Convert.ToInt32(this.comboBoxUnit.SelectedValue.ToString(), 10);

                m_bllBGDComeBackGoodsMXTab.Add(modelBGDComeBackGoodsMXTab);
                ShowAllMXRecordInDataGridView(m_nSelectBGDComeBackTabID.ToString(), this.comboBoxArriveNation.Text);
                //MessageBox.Show("数据添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

        private void buttonGoodsDetailDel_Click(object sender, EventArgs e)
        {
            DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTabOld = m_bllBGDComeBackGoodsMXTab.GetModel(m_nSelectBGDComeBackGoodsMXTabID);
            if (modelBGDComeBackGoodsMXTabOld == null)
            {
                MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("确实要删除该条记录!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                m_bllBGDComeBackGoodsMXTab.Delete(m_nSelectBGDComeBackGoodsMXTabID);

                this.textBoxGoodsNoDetail.Text = "";
                this.textBoxGoodsName.Text = "";
                this.textBoxMerial.Text = "";
                this.textBoxNum.Text = "";
                this.textBoxSingleCost.Text = "";
                this.textBoxTotalPrice.Text = "";
                this.textBoxZMianDetail.Text = "";
                this.textBoxGuiGe.Text = "";
                ShowAllMXRecordInDataGridView(m_nSelectBGDComeBackTabID.ToString(), this.comboBoxArriveNation.Text);
                MessageBox.Show("数据删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }

        private void buttonGoodsDetailModify_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTabOld = m_bllBGDComeBackGoodsMXTab.GetModel(m_nSelectBGDComeBackGoodsMXTabID);
                if (modelBGDComeBackGoodsMXTabOld == null)
                {
                    MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTab = new DGBY.Model.BGDComeBackGoodsMXTab();

                modelBGDComeBackGoodsMXTab.GoodsNo = this.textBoxGoodsNoDetail.Text;
                modelBGDComeBackGoodsMXTab.GoodsMXName = this.textBoxGoodsName.Text;
                modelBGDComeBackGoodsMXTab.GGXHZDEtc = this.textBoxMerial.Text;
                modelBGDComeBackGoodsMXTab.GGXHZDEtc2 = this.textBoxGuiGe.Text;
                modelBGDComeBackGoodsMXTab.FPieceNum = Convert.ToInt32(this.textBoxNum.Text, 10);
                modelBGDComeBackGoodsMXTab.SingleCost = Convert.ToDecimal(this.textBoxSingleCost.Text);
                modelBGDComeBackGoodsMXTab.TotalCost = modelBGDComeBackGoodsMXTab.SingleCost * (Decimal)modelBGDComeBackGoodsMXTab.FPieceNum;
                modelBGDComeBackGoodsMXTab.ZhengMian = this.textBoxZMianDetail.Text;
                modelBGDComeBackGoodsMXTab.BGDComeBackTabID = m_nSelectBGDComeBackTabID;
                modelBGDComeBackGoodsMXTab.BGDComeBackGoodsMXTabID = modelBGDComeBackGoodsMXTabOld.BGDComeBackGoodsMXTabID;
                modelBGDComeBackGoodsMXTab.RecvGoodsNote = modelBGDComeBackGoodsMXTabOld.RecvGoodsNote;
                modelBGDComeBackGoodsMXTab.SendGoodsNote = modelBGDComeBackGoodsMXTabOld.SendGoodsNote;


                if (this.comboBoxUnit.SelectedValue != null)
                    modelBGDComeBackGoodsMXTab.NumDanWeiTabID = Convert.ToInt32(this.comboBoxUnit.SelectedValue.ToString(), 10);

                m_bllBGDComeBackGoodsMXTab.Update(modelBGDComeBackGoodsMXTab);
                ShowAllMXRecordInDataGridView(m_nSelectBGDComeBackTabID.ToString(), this.comboBoxArriveNation.Text);
                MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

        private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            ClassUltraGridCommonSet.ultraGrid1_InitializeRowFilter(e);
            ClassUltraGridCommonSet.InitUltraWinGridRowNumSetting(e);
        }

        private void ultraGrid1_AfterCellActivate(object sender, EventArgs e)
        {
            int iIndex = this.ultraGrid1.ActiveCell.Row.Index;
            if (iIndex < 0)
                return;


            string strBGDComeBackTabID = this.ultraGrid1.Rows[this.ultraGrid1.ActiveCell.Row.Index].Cells[0].Text;
            m_nSelectBGDComeBackTabID = Convert.ToInt32(strBGDComeBackTabID, 10);
            cellBGDComeBackTabClick();
        }

        private void ultraGrid2_AfterCellActivate(object sender, EventArgs e)
        {
            int iIndex = this.ultraGrid2.ActiveCell.Row.Index;
            if (iIndex < 0)
                return;
            string strTemp = this.ultraGrid2.Rows[this.ultraGrid2.ActiveCell.Row.Index].Cells[3].Text;
            if (strTemp == "合计")
                return;
            string strBGDComeBackGoodsMXTabID = this.ultraGrid2.Rows[this.ultraGrid2.ActiveCell.Row.Index].Cells[0].Text;
            m_nSelectBGDComeBackGoodsMXTabID = Convert.ToInt32(strBGDComeBackGoodsMXTabID, 10);
            cellBGDComeBackGoodsMXTabClick();
        }

        private void ultraGrid2_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            ClassUltraGridCommonSet.ultraGrid1_InitializeRowFilter(e);
            ClassUltraGridCommonSet.InitUltraWinGridRowNumSetting(e);
        }


        private void textBoxSingleCost_TextChanged_1(object sender, EventArgs e)
        {
            if (this.textBoxNum.Text != "" && this.textBoxSingleCost.Text != "" && !m_bFlag)
            {
                m_bFlag = true;
                int nFPieceNum = Convert.ToInt32(this.textBoxNum.Text, 10);
                Decimal dTotalCost = Convert.ToDecimal(this.textBoxSingleCost.Text) * (Decimal)nFPieceNum;
                this.textBoxTotalPrice.Text = dTotalCost.ToString();
                m_bFlag = false;
            }

        }

        private void textBoxTotalPrice_TextChanged_1(object sender, EventArgs e)
        {
            if (this.textBoxNum.Text != "" && this.textBoxTotalPrice.Text != "" && !m_bFlag)
            {
                m_bFlag = true;
                int nFPieceNum = Convert.ToInt32(this.textBoxNum.Text, 10);
                if (nFPieceNum > 0)
                {
                    Decimal dSingleCost = Convert.ToDecimal(this.textBoxTotalPrice.Text) / (Decimal)nFPieceNum;
                    this.textBoxSingleCost.Text = dSingleCost.ToString();
                }
                m_bFlag = false;

            }
        }

        private void buttonInsert_Click(object sender, EventArgs e)
        {
            //DGBY.Model.BGDComeBackGoodsMXTab modelBGDComeBackGoodsMXTab = new DGBY.Model.BGDComeBackGoodsMXTab();

            //modelBGDComeBackGoodsMXTab.GoodsNo = this.textBoxGoodsNoDetail.Text;
            //modelBGDComeBackGoodsMXTab.GoodsMXName = this.textBoxGoodsName.Text;
            //modelBGDComeBackGoodsMXTab.GGXHZDEtc = this.textBoxMerial.Text;
            //modelBGDComeBackGoodsMXTab.FPieceNum = Convert.ToInt32(this.textBoxNum.Text, 10);
            //modelBGDComeBackGoodsMXTab.SingleCost = Convert.ToDecimal(this.textBoxSingleCost.Text);
            //modelBGDComeBackGoodsMXTab.TotalCost = Convert.ToDecimal(this.textBoxTotalPrice.Text);
            //modelBGDComeBackGoodsMXTab.ZhengMian = this.textBoxZMianDetail.Text;
            //modelBGDComeBackGoodsMXTab.BGDComeBackTabID = m_nSelectBGDComeBackTabID;


            //if (this.comboBoxCoinUnit.SelectedValue != null)
            //    modelBGDComeBackGoodsMXTab.BiZhiTabID = Convert.ToInt32(this.comboBoxCoinUnit.SelectedValue.ToString(), 10);
            //if (this.comboBoxUnit.SelectedValue != null)
            //    modelBGDComeBackGoodsMXTab.NumDanWeiTabID = Convert.ToInt32(this.comboBoxUnit.SelectedValue.ToString(), 10);

            //m_bllBGDComeBackGoodsMXTab.Add(modelBGDComeBackGoodsMXTab);
            //ShowAllMXRecordInDataGridView(m_nSelectBGDComeBackTabID.ToString(), this.comboBoxArriveNation.Text);
        }

        private void Frm_BGDComeBack_Activated(object sender, EventArgs e)
        {
            InitCombox();
        }

        private void Frm_BGDComeBack_Deactivate(object sender, EventArgs e)
        {
            Frm_Main.m_nContractSelectValue = (int)this.comboBoxContractNo.SelectedValue;
        }

        private void buttonSyncDetail_Click(object sender, EventArgs e)
        {
         
        }

    }
}